package com.ithiema.reflet.demo.demo2;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;

public class Demo2 {
    public static void main(String[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchFieldException {
        Class<Student> studentClass = Student.class;
        Constructor<Student> constructor = studentClass.getConstructor();
        Student student = constructor.newInstance();
        Student student1 = studentClass.newInstance();
        //
        Constructor<Student> constructor1 = studentClass.getConstructor(String.class, int.class, String.class);
        Student student2 = constructor1.newInstance("zahngsan", 23, "女");

        ArrayList<String > list=new ArrayList<>();
        Class<ArrayList> arrayListClass = ArrayList.class;
        Field sizeField = arrayListClass.getDeclaredField("size");
        sizeField.setAccessible(true);
        sizeField.set(list,10);
        System.out.println(list.size());





    }
}
